<template>
    <div class="tmpl">
        <nav-bar title="新闻列表"></nav-bar>
        <!-- MUI 图文列表 -->
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="list in lists" :key="list.id">
                <router-link :to="{name: 'news.detail', query: {id:list.id}}">
                    <img class="mui-media-object mui-pull-left" :src="list.img_url">
                    <div class="mui-media-body">
                        <span></span>
                        <div class="news-desc">
                            <p>点击数:{{list.count}}</p>
                            <p>发表时间:{{list.add_time | convertDate}}</p>
                        </div>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
    import moment from 'moment';
    export default {
        data() {
            return {
                lists: []
            }
        },
        created() {
            this.$ajax.get('list').then(res => {
                this.lists = res.data.result;
            }).catch(err => {
                console.log(err);
            })
        },
        methods: {
            formDate(value)
            {
                moment().locale('zh-cn');
                //return moment().format('MMMM Do YYYY, h:mm:ss a');
                return this.$moment().format('YYYY-MM-DD HH:mm:ss');
            }
        }
    }
</script>

<style scoped>

</style>